<template>
  <div>
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column label="日志ID" width="120">
        <template v-slot="scope">{{ scope.row.logid }}</template>
      </el-table-column>
      <el-table-column prop="visitorip" label="IP地址" width="120"></el-table-column>
      <el-table-column
        prop="visitortime"
        label="时间"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="visitorclass"
        label="路径"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="visitormethod"
        label="类别"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="other"
        label="其他"
        show-overflow-tooltip
      ></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getLogs } from "@/api/log"; 

export default {
  data() {
    return {
      tableData: [], 
    };
  },
  methods: {
    handleSelectionChange(selection) {
      console.log("选中的数据:", selection);
    },

    fetchLogs() {
      getLogs() 
        .then((response) => {
          this.tableData = response.data; 
        })
        .catch((error) => {
          console.error("获取日志数据失败:", error);
        });
    },
  },
  mounted() {
    this.fetchLogs(); 
  },
};
</script>